using UpdateProgram_;

namespace UpdateProgram
{
    internal static class Program
    {
        /// <summary>
        ///     The main entry point for the application.
        /// </summary>
        [STAThread]
        private static void Main()
        {
            Application.ThreadException += (sender, e) =>
            {
                MessageBox.Show(e.Exception.Message);
            };
            var temp = Update.HasNewVersion();
            if (temp.Result)
            {
                if (Update.IsSystemPath() && !Update.IsAdministrator())
                {
                    Update.ReStartAppWithAdministrator();
                }
                else
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Form1(temp));
                }
            }
            else
            {
                Environment.Exit(0);
            }
        }
    }
}